package cn.bs.busuo.front.hotel.dao.persist.repository.impl;


import cn.bs.busuo.front.hotel.dao.persist.mapper.*;
import cn.bs.busuo.front.hotel.dao.persist.repository.HotelRepository;
import cn.bs.busuo.front.hotel.pojo.entity.*;
import cn.bs.busuo.front.hotel.pojo.param.AddNewRoomParam;
import cn.bs.busuo.front.hotel.pojo.param.DeleteHotelRoomTypeParam;
import cn.bs.busuo.front.hotel.pojo.param.DeleteHotelWorkerParam;
import cn.bs.busuo.front.hotel.pojo.param.DeleteRoomParam;
import cn.bs.busuo.front.hotel.pojo.vo.HotelRoomTypeEnabledVO;
import cn.bs.busuo.front.hotel.pojo.vo.HotelVO;
import cn.bs.busuo.front.hotel.pojo.vo.HotelWorkerVO;
import cn.bs.busuo.front.hotel.pojo.vo.HotelsRoomTypeCheckVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class HotelRepositoryImpl implements HotelRepository {
    @Autowired(required = false)
    private HotelMapper hotelMapper;
    @Autowired(required = false)
    private SightMapper sightMapper;
    @Autowired(required = false)
    private SightNearHotelMapper sightNearHotelMapper;
    @Autowired(required = false)
    private CityMapper cityMapper;
    @Autowired(required = false)
    private CityHotelsMapper cityHotelsMapper;
    @Autowired(required = false)
    private HotelNotSetCityMapper hotelNotSetCityMapper;
    @Autowired(required = false)
    private HotelNotSetSightMapper hotelNotSetSightMapper;
    @Autowired(required = false)
    private UserMapper userMapper;
    @Autowired(required = false)
    private HotelWorkerMapper hotelWorkerMapper;
    @Autowired(required = false)
    private UserRoleMapper userRoleMapper;
    @Autowired
    private HotelsRoomTypeMapper hotelsRoomTypeMapper;
    @Override
    public int addNew(Hotel hotel) {
        return hotelMapper.insert(hotel);
    }

    @Override
    public int selectSightIfExist(Long sightsId) {
        return sightMapper.selectSightIfExist(sightsId);
    }

    @Override
    public int setPositionAboutSight(SightsNearHotels sightsNearHotels) {
        return sightNearHotelMapper.insert(sightsNearHotels) ;
    }

    @Override
    public int selectCityIfExist(Long cityId) {
        return cityMapper.selectCityIfExist(cityId);
    }

    @Override
    public int setPositionAboutCity(CityHotels cityHotels) {
        return cityHotelsMapper.insert(cityHotels);
    }

    @Override
    public int addNewHotelToNotSetCity(HotelsNotSetCity hotelsNotSetCity) {
        return hotelNotSetCityMapper.insert(hotelsNotSetCity);
    }

    @Override
    public int addNewHotelToNotSetSight(HotelsNotSetSight hotelsNotSetSight) {
        return hotelNotSetSightMapper.insert(hotelsNotSetSight);
    }

    @Override
    public int deleteHotelsNotSetSight(Long hotelsId) {
        return hotelNotSetSightMapper.deleteByHotelsId(hotelsId);
    }

    @Override
    public int deleteHotelsNotSetCity(Long hotelId) {
        return hotelNotSetCityMapper.deleteByHotelsId(hotelId);
    }

    @Override
    public int deleteById(Long hotelId) {
        return hotelMapper.deleteEnableById(hotelId);
    }

    @Override
    public int updateById(Hotel hotel) {
        return hotelMapper.updateById(hotel);
    }

    @Override
    public int selectHotelNameIfSimilar(String hotelName) {
        return hotelMapper.selectHotelNameIfSimilar(hotelName);
    }

    @Override
    public Long selectIdByHotelName(String hotelName) {
        return hotelMapper.selectIdByHotelName(hotelName);
    }

    @Override
    public List<HotelVO> selectAll() {
        return hotelMapper.selectAll();
    }

    @Override
    public HotelVO selectById(Long hotelId) {
        return hotelMapper.selectById1(hotelId);
    }

    @Override
    public List<HotelVO> selectHotelByCityId(Long cityId) {
        return hotelMapper.selectHotelByCityId(cityId);
    }

    @Override
    public int selectHotelIfEnable(Long id) {
        return hotelMapper.selectHotelIfEnable(id);
    }

    @Override
    public List<HotelVO> selectHotelBySightId(Long sightId) {
        return hotelMapper.selectHotelBySightId(sightId);
    }

    @Override
    public List<HotelVO> selectHotelWhichNotSetCity() {
        return hotelMapper.selectHotelWhichNotSetCity();
    }

    @Override
    public List<HotelVO> selectHotelWhichNotSetSight() {
        return hotelMapper.selectHotelWhichNotSetSight();
    }

    @Override
    public int selectUserIfExist(Long userId) {
        return userMapper.selectUserIfExist(userId);
    }

    @Override
    public int selectHotelWorkerIfExist(Long HotelId, Long userId) {
        return hotelWorkerMapper.selectHotelWorkerIfExist(HotelId,userId);
    }

    @Override
    public int addHotelWorker(HotelWorker hotelWorker) {
        return hotelWorkerMapper.insert(hotelWorker);
    }

    @Override
    public int addHotelWorkerRole(UserRole userRole) {
        return userRoleMapper.insert(userRole);
    }

    @Override
    public int deleteHotelWorker(DeleteHotelWorkerParam deleteHotelWorkerParam) {
        return hotelWorkerMapper.deleteHotelWorker(deleteHotelWorkerParam);
    }

    @Override
    public int deleteHotelWorkerRole(Long userId) {
        return userRoleMapper.deleteUserRoleByUserId(userId,9L);
    }

    @Override
    public int addNewRoomType(HotelsRoomType hotelsRoomType) {
        return hotelsRoomTypeMapper.insert(hotelsRoomType);
    }

    @Override
    public List<HotelWorkerVO> selectHotelWorker(Long hotelId) {
        return hotelWorkerMapper.selectHotelWorker(hotelId);
    }

    @Override
    public int deleteRoomTypeById(DeleteHotelRoomTypeParam deleteHotelRoomTypeParam) {
        return hotelsRoomTypeMapper.deleteById(deleteHotelRoomTypeParam.getId());
    }

    @Override
    public List<HotelsRoomTypeCheckVO> selectRoomTypeWhichNotCheck() {
        return hotelsRoomTypeMapper.selectRoomTypeWhichNotCheck();
    }

    @Override
    public List<HotelsRoomTypeCheckVO> selectRoomTypeWhichCheck() {
        return hotelsRoomTypeMapper.selectRoomTypeWhichCheck();
    }

    @Override
    public int checkRoomTypeAccess(Long id,Byte checkState) {
        return hotelsRoomTypeMapper.checkRoomTypeAccess(id,checkState);
    }

    @Override
    public int checkRoomTypeRefused(Long id, Byte checkState) {
        return hotelsRoomTypeMapper.checkRoomTypeRefused(id,checkState);
    }

    @Override
    public List<HotelRoomTypeEnabledVO> selectHotelRoomType(Long hotelId) {
        return hotelsRoomTypeMapper.selectHotelRoomType(hotelId);
    }

    @Override
    public int enableRoomType(Long id) {
        return hotelsRoomTypeMapper.enableRoomType(id);
    }

    @Override
    public int disableRoomType(Long id) {
        return hotelsRoomTypeMapper.disableRoomType(id);
    }

    @Override
    public int addRoom(AddNewRoomParam addNewRoomParam) {
        return hotelsRoomTypeMapper.addNewRoom(addNewRoomParam);
    }

    @Override
    public int deleteRoom(DeleteRoomParam deleteRoomParam) {
        return hotelsRoomTypeMapper.deleteRoom(deleteRoomParam);
    }

    @Override
    public int selectUserIfBoss(Long userId,Long hotelId) {
        return hotelWorkerMapper.selectUserIfBoss(userId,hotelId);
    }


}
